<?php

class Admin_Model_Posts extends Zend_Db_Table_Abstract {

    /**
     * Model posts
     * @author Nguyen Manh Hung
     */
    protected $_name = TABLE_POSTS;
    protected $_id = 'id';

    /**
     *
     * @author Nguyen manh Hung
     */
    public function insertPost($data) {
        $current_time = new Zend_Db_Expr('NOW()');
        $data['post_date'] = $current_time;
        $data['post_modified'] = $current_time;
        $id = $this->insert($data);        
        return $id;
    }

    /**
     * update post
     * @author Nguyen Manh Hung
     */
    public function updatePost($id, $data) {
        $current_time = new Zend_Db_Expr('NOW()');
        $data['post_modified'] = $current_time;
        return $this->update($data, array('id=' . $id));
    }
}